Skip to content

Commit

Permalink
feat: change after change in imported crate
Browse files Browse the repository at this point in the history
  • Loading branch information
n00m4d committed Sep 17, 2024
1 parent de0c59c commit af14fcb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
6 changes: 4 additions & 2 deletions programs/bubblegum/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
)
Expand Down Expand Up @@ -172,11 +167,11 @@ pub(crate) fn check_stake<'info>(
let registrar: &Registrar = bytemuck::from_bytes(&registrar_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;
Expand Down
23 changes: 10 additions & 13 deletions programs/bubblegum/program/tests/batch-mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit af14fcb

Please sign in to comment.