From 5f137d20e52a2fe808f85e122f2398bec36b7ce3 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 24 Oct 2023 17:26:23 +0200 Subject: [PATCH] import processor code from token-group example program --- Cargo.lock | 1 + token-collection/program/Cargo.toml | 1 + token-collection/program/src/processor.rs | 62 ++++------------------- 3 files changed, 11 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70797190722..affb2fd69e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7353,6 +7353,7 @@ dependencies = [ "spl-program-error 0.3.0", "spl-token-2022 0.9.0", "spl-token-client", + "spl-token-group-example", "spl-token-group-interface", "spl-token-metadata-interface 0.2.0", "spl-type-length-value 0.3.0", diff --git a/token-collection/program/Cargo.toml b/token-collection/program/Cargo.toml index 713e39558ad..33f2c54ee81 100644 --- a/token-collection/program/Cargo.toml +++ b/token-collection/program/Cargo.toml @@ -16,6 +16,7 @@ solana-program = "1.17.2" spl-pod = { version = "0.1.0", path = "../../libraries/pod" } spl-program-error = { version = "0.3.0" , path = "../../libraries/program-error" } spl-token-2022 = { version = "0.9.0", path = "../../token/program-2022", features = ["no-entrypoint"] } +spl-token-group-example = { version = "0.1.0", path = "../../token-group/example", features = ["no-entrypoint"] } spl-token-group-interface = { version = "0.1.0", path = "../../token-group/interface" } spl-token-metadata-interface = { version = "0.2", path = "../../token-metadata/interface" } spl-type-length-value = { version = "0.3.0", path = "../../libraries/type-length-value" } diff --git a/token-collection/program/src/processor.rs b/token-collection/program/src/processor.rs index edfcf9103d4..c5153a03771 100644 --- a/token-collection/program/src/processor.rs +++ b/token-collection/program/src/processor.rs @@ -18,9 +18,7 @@ use { }, spl_token_group_interface::{ error::TokenGroupError, - instruction::{ - InitializeGroup, TokenGroupInstruction, UpdateGroupAuthority, UpdateGroupMaxSize, - }, + instruction::{InitializeGroup, TokenGroupInstruction}, state::{TokenGroup, TokenGroupMember}, }, spl_token_metadata_interface::state::TokenMetadata, @@ -93,54 +91,6 @@ pub fn process_initialize_collection( Ok(()) } -/// Processes an -/// [UpdateGroupMaxSize](enum.GroupInterfaceInstruction.html) -/// instruction to update the max size of a collection. -pub fn process_update_collection_max_size( - _program_id: &Pubkey, - accounts: &[AccountInfo], - data: UpdateGroupMaxSize, -) -> ProgramResult { - let account_info_iter = &mut accounts.iter(); - - let collection_info = next_account_info(account_info_iter)?; - let update_authority_info = next_account_info(account_info_iter)?; - - let mut buffer = collection_info.try_borrow_mut_data()?; - let mut state = TlvStateMut::unpack(&mut buffer)?; - let collection = state.get_first_value_mut::()?; - - check_update_authority(update_authority_info, &collection.update_authority)?; - - collection.update_max_size(data.max_size.into())?; - - Ok(()) -} - -/// Processes an -/// [UpdateGroupAuthority](enum.GroupInterfaceInstruction.html) -/// instruction to update the authority of a collection. -pub fn process_update_collection_authority( - _program_id: &Pubkey, - accounts: &[AccountInfo], - data: UpdateGroupAuthority, -) -> ProgramResult { - let account_info_iter = &mut accounts.iter(); - - let collection_info = next_account_info(account_info_iter)?; - let update_authority_info = next_account_info(account_info_iter)?; - - let mut buffer = collection_info.try_borrow_mut_data()?; - let mut state = TlvStateMut::unpack(&mut buffer)?; - let collection = state.get_first_value_mut::()?; - - check_update_authority(update_authority_info, &collection.update_authority)?; - - collection.update_authority = data.new_authority; - - Ok(()) -} - /// Processes an [InitializeMember](enum.GroupInterfaceInstruction.html) /// instruction pub fn process_initialize_collection_member( @@ -192,11 +142,17 @@ pub fn process(program_id: &Pubkey, accounts: &[AccountInfo], input: &[u8]) -> P } TokenGroupInstruction::UpdateGroupMaxSize(data) => { msg!("Instruction: UpdateCollectionMaxSize"); - process_update_collection_max_size(program_id, accounts, data) + // Same functionality as the example program + spl_token_group_example::processor::process_update_group_max_size( + program_id, accounts, data, + ) } TokenGroupInstruction::UpdateGroupAuthority(data) => { msg!("Instruction: UpdateCollectionAuthority"); - process_update_collection_authority(program_id, accounts, data) + // Same functionality as the example program + spl_token_group_example::processor::process_update_group_authority( + program_id, accounts, data, + ) } TokenGroupInstruction::InitializeMember(_) => { msg!("Instruction: InitializeCollectionMember");