Skip to content

Commit 1261890

Browse files
Fix: include UnwrapLamports (45) in TokenInstruction::try_from
1 parent 90b8f5c commit 1261890

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pinocchio/interface/src/instruction.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use {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

571575
impl 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

Comments
 (0)