From b12a69ab10dacc0990cce6c8e22a78a5b889eb27 Mon Sep 17 00:00:00 2001 From: blockiosaurus Date: Tue, 9 Apr 2024 13:58:58 -0400 Subject: [PATCH] Minor cleanup. --- .../program/src/processor/metadata/mint.rs | 7 +---- .../program/src/utils/programmable_asset.rs | 28 +++++++++++-------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/programs/token-metadata/program/src/processor/metadata/mint.rs b/programs/token-metadata/program/src/processor/metadata/mint.rs index 10a8e034..4e0c6358 100644 --- a/programs/token-metadata/program/src/processor/metadata/mint.rs +++ b/programs/token-metadata/program/src/processor/metadata/mint.rs @@ -212,22 +212,17 @@ pub fn mint_v1(program_id: &Pubkey, ctx: Context, args: MintArgs) -> Progr .edition_nonce .ok_or(MetadataError::NotAMasterEdition)?], ]; - // let master_edition_key = - // Pubkey::create_program_address(master_edition_seeds, program_id)?; let master_edition_info = ctx .accounts .master_edition_info .ok_or(MetadataError::MissingMasterEditionAccount)?; - // if !cmp_pubkeys(master_edition_info.key, &master_edition_key) { - // return Err(MetadataError::InvalidMasterEdition.into()); - // } assert_derivation_with_bump( &crate::ID, master_edition_info, master_edition_seeds, - MetadataError::MissingMasterEditionAccount, + MetadataError::InvalidMasterEdition, )?; // thaw the token account for programmable assets; the account diff --git a/programs/token-metadata/program/src/utils/programmable_asset.rs b/programs/token-metadata/program/src/utils/programmable_asset.rs index 35345a70..04d901d8 100644 --- a/programs/token-metadata/program/src/utils/programmable_asset.rs +++ b/programs/token-metadata/program/src/utils/programmable_asset.rs @@ -101,7 +101,7 @@ pub fn freeze<'a>( } None => assert_derivation(&crate::ID, &edition, &edition_info_path), }?; - let mut edition_info_seeds = edition_info_path.clone(); + let mut edition_info_seeds = edition_info_path; let binding = [bump]; edition_info_seeds.push(&binding); @@ -143,9 +143,8 @@ pub fn thaw<'a>( } None => assert_derivation(&crate::ID, &edition_info, &edition_info_path), }?; - let mut edition_info_seeds = edition_info_path.clone(); let binding = [bump]; - edition_info_seeds.push(&binding); + let edition_info_seeds = [edition_info_path, vec![&binding]].concat(); invoke_signed( &thaw_account( @@ -394,18 +393,23 @@ pub(crate) fn clear_close_authority(params: ClearCloseAuthorityParams) -> Progra return Err(MetadataError::InvalidCloseAuthority.into()); } - let path = vec![ - "metadata".as_bytes(), - crate::ID.as_ref(), - mint_info.key.as_ref(), - "edition".as_bytes(), - ]; - let bump = edition_bump.unwrap_or(Pubkey::find_program_address(&path, &crate::ID).1); + let bump = edition_bump.unwrap_or( + Pubkey::find_program_address( + &[ + PREFIX.as_bytes(), + crate::ID.as_ref(), + mint_info.key.as_ref(), + EDITION.as_bytes(), + ], + &crate::ID, + ) + .1, + ); let seeds = &[ - "metadata".as_bytes(), + PREFIX.as_bytes(), crate::ID.as_ref(), mint_info.key.as_ref(), - "edition".as_bytes(), + EDITION.as_bytes(), &[bump], ];