diff --git a/token-group/interface/Cargo.toml b/token-group/interface/Cargo.toml index 40271ad1092..b748beab31b 100644 --- a/token-group/interface/Cargo.toml +++ b/token-group/interface/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" [dependencies] bytemuck = "1.14.0" -solana-program = "1.16.3" +solana-program = "1.16.16" spl-discriminator = { version = "0.1.0" , path = "../../libraries/discriminator" } spl-pod = { version = "0.1.0" , path = "../../libraries/pod", features = ["borsh"] } spl-program-error = { version = "0.3.0" , path = "../../libraries/program-error" } diff --git a/token-group/interface/src/instruction.rs b/token-group/interface/src/instruction.rs index 74d862102f4..305f28e4684 100644 --- a/token-group/interface/src/instruction.rs +++ b/token-group/interface/src/instruction.rs @@ -18,7 +18,7 @@ use { /// Instruction data for initializing a new `Group` #[repr(C)] #[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, SplDiscriminate)] -#[discriminator_hash_input("spl_token_group_interface:initialize_group")] +#[discriminator_hash_input("spl_token_group_interface:initialize_token_group")] pub struct InitializeGroup { /// Update authority for the group pub update_authority: OptionalNonZeroPubkey, @@ -38,7 +38,7 @@ pub struct UpdateGroupMaxSize { /// Instruction data for updating the authority of a `Group` #[repr(C)] #[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, SplDiscriminate)] -#[discriminator_hash_input("spl_token_group_interface:update_group_authority")] +#[discriminator_hash_input("spl_token_group_interface:update_authority")] pub struct UpdateGroupAuthority { /// New authority for the group, or unset if `None` pub new_authority: OptionalNonZeroPubkey, @@ -89,7 +89,8 @@ pub enum TokenGroupInterfaceInstruction { /// Accounts expected by this instruction: /// /// 0. `[w]` Member - /// 1. `[s]` Member update authority + /// 1. `[]` Member mint + /// 1. `[s]` Member mint authority /// 2. `[w]` Group /// 3. `[s]` Group update authority InitializeMember(InitializeMember), @@ -155,7 +156,6 @@ pub fn initialize_group( mint_authority: &Pubkey, update_authority: Option, max_size: u32, - extra_account_metas: &[AccountMeta], ) -> Instruction { let update_authority = OptionalNonZeroPubkey::try_from(update_authority) .expect("Failed to deserialize `Option`"); @@ -164,16 +164,13 @@ pub fn initialize_group( max_size: max_size.into(), }) .pack(); - let mut accounts = vec![ - AccountMeta::new(*group, false), - AccountMeta::new_readonly(*mint, false), - AccountMeta::new_readonly(*mint_authority, true), - ]; - accounts.extend_from_slice(extra_account_metas); - Instruction { program_id: *program_id, - accounts, + accounts: vec![ + AccountMeta::new(*group, false), + AccountMeta::new_readonly(*mint, false), + AccountMeta::new_readonly(*mint_authority, true), + ], data, } } @@ -227,21 +224,21 @@ pub fn update_group_authority( pub fn initialize_member( program_id: &Pubkey, member: &Pubkey, - member_update_authority: &Pubkey, + member_mint: &Pubkey, + member_mint_authority: &Pubkey, group: &Pubkey, group_update_authority: &Pubkey, ) -> Instruction { let data = TokenGroupInterfaceInstruction::InitializeMember(InitializeMember {}).pack(); - let accounts = vec![ - AccountMeta::new(*member, false), - AccountMeta::new_readonly(*member_update_authority, true), - AccountMeta::new(*group, false), - AccountMeta::new_readonly(*group_update_authority, true), - ]; - Instruction { program_id: *program_id, - accounts, + accounts: vec![ + AccountMeta::new(*member, false), + AccountMeta::new_readonly(*member_mint, false), + AccountMeta::new_readonly(*member_mint_authority, true), + AccountMeta::new(*group, false), + AccountMeta::new_readonly(*group_update_authority, true), + ], data, } } @@ -278,7 +275,7 @@ mod test { max_size: 100.into(), }; let instruction = TokenGroupInterfaceInstruction::InitializeGroup(data); - let preimage = hash::hashv(&[format!("{NAMESPACE}:initialize_group").as_bytes()]); + let preimage = hash::hashv(&[format!("{NAMESPACE}:initialize_token_group").as_bytes()]); let discriminator = &preimage.as_ref()[..ArrayDiscriminator::LENGTH]; instruction_pack_unpack::(instruction, discriminator, data); } @@ -300,7 +297,7 @@ mod test { new_authority: OptionalNonZeroPubkey::default(), }; let instruction = TokenGroupInterfaceInstruction::UpdateGroupAuthority(data); - let preimage = hash::hashv(&[format!("{NAMESPACE}:update_group_authority").as_bytes()]); + let preimage = hash::hashv(&[format!("{NAMESPACE}:update_authority").as_bytes()]); let discriminator = &preimage.as_ref()[..ArrayDiscriminator::LENGTH]; instruction_pack_unpack::(instruction, discriminator, data); } diff --git a/token-group/interface/src/state.rs b/token-group/interface/src/state.rs index d26fd2fd2e8..8c5993e5cb6 100644 --- a/token-group/interface/src/state.rs +++ b/token-group/interface/src/state.rs @@ -63,14 +63,14 @@ pub struct Member { /// The pubkey of the `Group` pub group: Pubkey, /// The member number - pub member_number: u32, + pub member_number: PodU32, } impl Member { /// Creates a new `Member` state pub fn new(group: Pubkey, member_number: u32) -> Self { Self { group, - member_number, + member_number: member_number.into(), } } } @@ -110,7 +110,7 @@ mod tests { let member = Member { group: Pubkey::new_unique(), - member_number: 0, + member_number: 0.into(), }; let account_size = TlvStateBorrowed::get_base_len()