Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pinocchio/interface/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use {crate::error::TokenError, pinocchio::program_error::ProgramError};


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Not needed.

/// Instructions supported by the token program.
#[repr(u8)]
#[derive(Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -536,6 +537,8 @@ pub enum TokenInstruction {
/// other `batch` instruction; an error will be raised when this is
/// detected.
Batch = 255,


Comment on lines +540 to +541
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Not needed.

// Any new variants also need to be added to program-2022 `TokenInstruction`, so that the
// latter remains a superset of this instruction set. New variants also need to be added to
// token/js/src/instructions/types.ts to maintain @solana/spl-token compatibility
Expand All @@ -547,7 +550,7 @@ impl TryFrom<u8> for TokenInstruction {
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
// SAFETY: `value` is guaranteed to be in the range of the enum variants.
0..=24 | 38 | 255 => Ok(unsafe { core::mem::transmute::<u8, TokenInstruction>(value) }),
0..=24 | 38 | 45 | 255 => Ok(unsafe { core::mem::transmute::<u8, TokenInstruction>(value) }),
_ => Err(TokenError::InvalidInstruction.into()),
}
}
Expand All @@ -566,6 +569,7 @@ pub enum AuthorityType {
AccountOwner,
/// Authority to close a token account
CloseAccount,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Not needed.

}

impl TryFrom<u8> for AuthorityType {
Expand Down Expand Up @@ -595,10 +599,13 @@ mod tests {
assert_eq!(
TokenInstruction::from_repr(variant_u8),
Some(TokenInstruction::try_from(variant_u8).unwrap())

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Not needed.

);
assert_eq!(TokenInstruction::try_from(variant_u8).unwrap(), variant);
}
}


Comment on lines +607 to +608
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Not needed.


#[test]
fn test_authority_type_from_u8_exhaustive() {
Expand Down
Loading