From af14fcb3b2339150cd95fcedf4e164feba1947c5 Mon Sep 17 00:00:00 2001 From: n00m4d Date: Tue, 17 Sep 2024 16:16:12 +0200 Subject: [PATCH] feat: change after change in imported crate --- programs/bubblegum/program/Cargo.toml | 6 +++-- .../src/processor/finalize_tree_with_root.rs | 15 ++++-------- .../bubblegum/program/tests/batch-mint.rs | 23 ++++++++----------- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/programs/bubblegum/program/Cargo.toml b/programs/bubblegum/program/Cargo.toml index 38815a3..d88fe6a 100644 --- a/programs/bubblegum/program/Cargo.toml +++ b/programs/bubblegum/program/Cargo.toml @@ -17,7 +17,9 @@ no-idl = [] no-log-ix-name = [] cpi = ["no-entrypoint"] test-sbf = [] -default = [] +default = ["mainnet"] +mainnet = ["mpl-common-constants/mainnet"] +devnet = ["mpl-common-constants/devnet"] [dependencies] anchor-lang = { version = "0.29.0", features = ["init-if-needed"] } @@ -31,7 +33,7 @@ spl-associated-token-account = { version = ">= 1.1.3, < 3.0", features = ["no-en spl-token = { version = ">= 3.5.0, < 5.0", features = ["no-entrypoint"] } mplx-staking-states = { git = "https://github.com/adm-metaex/mplx-staking.git" } mplx-rewards = { git = "https://github.com/adm-metaex/mplx-rewards.git", features = ["no-entrypoint"] } -mpl-common-constants = { git = "https://github.com/adm-metaex/mpl-common-constants.git", branch = "main", features = ["mainnet"] } +mpl-common-constants = { git = "https://github.com/adm-metaex/mpl-common-constants.git", branch = "main" } [dev-dependencies] async-trait = "0.1.71" diff --git a/programs/bubblegum/program/src/processor/finalize_tree_with_root.rs b/programs/bubblegum/program/src/processor/finalize_tree_with_root.rs index e3849bb..c91a009 100644 --- a/programs/bubblegum/program/src/processor/finalize_tree_with_root.rs +++ b/programs/bubblegum/program/src/processor/finalize_tree_with_root.rs @@ -60,7 +60,7 @@ pub(crate) fn finalize_tree_with_root<'info>( ); require!( - ctx.accounts.fee_receiver.key.to_string() == FEE_RECEIVER, + ctx.accounts.fee_receiver.key.to_bytes() == FEE_RECEIVER, BubblegumError::FeeReceiverMismatch ); check_stake( @@ -129,16 +129,11 @@ pub(crate) fn check_stake<'info>( BubblegumError::MiningOwnerMismatch ); - let realm_key = - Pubkey::from_str(DAO_PUBKEY).map_err(|_| BubblegumError::PubkeyReconstruction)?; - let realm_governing_mint_key = - Pubkey::from_str(DAO_GOVERNING_MINT).map_err(|_| BubblegumError::PubkeyReconstruction)?; - let generated_registrar = Pubkey::find_program_address( &[ - realm_key.to_bytes().as_ref(), + DAO_PUBKEY.as_ref(), b"registrar".as_ref(), - realm_governing_mint_key.to_bytes().as_ref(), + DAO_GOVERNING_MINT.as_ref(), ], &mplx_staking_states::ID, ) @@ -172,11 +167,11 @@ pub(crate) fn check_stake<'info>( let registrar: &Registrar = bytemuck::from_bytes(®istrar_bytes[DISCRIMINATOR_LEN..]); require!( - registrar.realm.to_string() == DAO_PUBKEY, + registrar.realm.to_bytes() == DAO_PUBKEY, BubblegumError::StakingRegistrarRealmMismatch ); require!( - registrar.realm_governing_token_mint.to_string() == DAO_GOVERNING_MINT, + registrar.realm_governing_token_mint.to_bytes() == DAO_GOVERNING_MINT, BubblegumError::StakingRegistrarRealmMismatch ); let voter_bytes = voter_acc.to_account_info().data; diff --git a/programs/bubblegum/program/tests/batch-mint.rs b/programs/bubblegum/program/tests/batch-mint.rs index 5ccc413..580be70 100644 --- a/programs/bubblegum/program/tests/batch-mint.rs +++ b/programs/bubblegum/program/tests/batch-mint.rs @@ -155,14 +155,11 @@ async fn initialize_staking_accounts( let mining_key = Pubkey::new_unique(); let reward_pool_key = Pubkey::new_unique(); - let realm_key = Pubkey::from_str(DAO_PUBKEY).unwrap(); - let realm_governing_mint_key = Pubkey::from_str(DAO_GOVERNING_MINT).unwrap(); - let registrar_key = Pubkey::find_program_address( &[ - realm_key.to_bytes().as_ref(), + DAO_PUBKEY.as_ref(), b"registrar".as_ref(), - realm_governing_mint_key.to_bytes().as_ref(), + DAO_GOVERNING_MINT.as_ref(), ], &mplx_staking_states::ID, ) @@ -185,8 +182,8 @@ async fn initialize_staking_accounts( let registrar = Registrar { governance_program_id: governance_program_id.clone(), - realm: realm_key, - realm_governing_token_mint: realm_governing_mint_key, + realm: Pubkey::new_from_array(DAO_PUBKEY), + realm_governing_token_mint: Pubkey::new_from_array(DAO_GOVERNING_MINT), realm_authority: realm_authority.clone(), voting_mints: [voting_mint_config, voting_mint_config], reward_pool: reward_pool_key, @@ -304,7 +301,7 @@ async fn test_prepare_tree_without_canopy() { let (registrar_key, voter_key, mining_key) = initialize_staking_accounts(&mut program_context).await; - let fee_receiver = Pubkey::from_str(FEE_RECEIVER).unwrap(); + let fee_receiver = Pubkey::new_from_array(FEE_RECEIVER); program_context .fund_account(tree.creator_pubkey(), 10_000_000_000) @@ -446,7 +443,7 @@ async fn test_prepare_tree_with_canopy() { .unwrap(); } - let fee_receiver = Pubkey::from_str(FEE_RECEIVER).unwrap(); + let fee_receiver = Pubkey::new_from_array(FEE_RECEIVER); let mut tree_tx_builder = tree.finalize_tree_with_root_tx( &program_context.test_context().payer, @@ -527,7 +524,7 @@ async fn test_put_wrong_canopy() { .unwrap(); } - let fee_receiver = Pubkey::from_str(FEE_RECEIVER).unwrap(); + let fee_receiver = Pubkey::new_from_array(FEE_RECEIVER); let mut tree_tx_builder = tree.finalize_tree_with_root_tx( &program_context.test_context().payer, @@ -637,7 +634,7 @@ async fn test_put_wrong_fee_receiver() { let (registrar_key, voter_key, mining_key) = initialize_staking_accounts(&mut program_context).await; - let fee_receiver = Pubkey::from_str(FEE_RECEIVER).unwrap(); + let fee_receiver = Pubkey::new_from_array(FEE_RECEIVER); program_context .fund_account(tree.creator_pubkey(), 10_000_000_000) @@ -718,7 +715,7 @@ async fn test_prepare_tree_with_collection() { ) .await; - let fee_receiver = Pubkey::from_str(FEE_RECEIVER).unwrap(); + let fee_receiver = Pubkey::new_from_array(FEE_RECEIVER); let rightmost_proof = tree.proof_of_leaf((num_of_assets_to_mint - 1) as u32); let rightmost_leaf = tree.get_node(num_of_assets_to_mint - 1); @@ -791,7 +788,7 @@ async fn test_prepare_tree_with_collection_wrong_authority() { ) .await; - let fee_receiver = Pubkey::from_str(FEE_RECEIVER).unwrap(); + let fee_receiver = Pubkey::new_from_array(FEE_RECEIVER); let rightmost_leaf = tree.get_node(num_of_assets_to_mint - 1);