use {
arch_program::{program_error::ProgramError, pubkey::Pubkey},
borsh::{BorshDeserialize, BorshSerialize},
};
#[derive(BorshSerialize, BorshDeserialize, Debug, Clone, PartialEq)]
pub enum MetadataInstruction {
CreateMetadata {
name: String,
symbol: String,
image: String,
description: String,
immutable: bool,
},
UpdateMetadata {
name: Option<String>,
symbol: Option<String>,
image: Option<String>,
description: Option<String>,
},
CreateAttributes {
data: Vec<(String, String)>,
},
ReplaceAttributes {
data: Vec<(String, String)>,
},
TransferAuthority {
new_authority: Pubkey,
},
MakeImmutable,
Anchor {
input_index: u32,
input_signer: Pubkey,
},
}
impl MetadataInstruction {
pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
borsh::from_slice(input).map_err(|_| ProgramError::InvalidInstructionData)
}
pub fn pack(&self) -> Vec<u8> {
borsh::to_vec(self).unwrap()
}
}