Skip to content

Commit

Permalink
Add print delegate to test util
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed Aug 27, 2024
1 parent d891ff3 commit 91c9a0d
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions programs/bubblegum/program/tests/utils/digital_asset.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#![allow(clippy::too_many_arguments)]

use mpl_token_metadata::{
accounts::{EditionMarker, MasterEdition, Metadata, MetadataDelegateRecord, TokenRecord},
accounts::{
EditionMarker, HolderDelegateRecord, MasterEdition, Metadata, MetadataDelegateRecord,
TokenRecord,
},
instructions::{
BurnBuilder, CreateBuilder, DelegateBuilder, LockBuilder, MintBuilder,
MintNewEditionFromMasterEditionViaToken,
Expand All @@ -10,7 +13,7 @@ use mpl_token_metadata::{
},
types::{
AuthorizationData, BurnArgs, Collection, CollectionDetails, CreateArgs, Creator,
DelegateArgs, LockArgs, MetadataDelegateRole, MintArgs,
DelegateArgs, HolderDelegateRole, LockArgs, MetadataDelegateRole, MintArgs,
MintNewEditionFromMasterEditionViaTokenArgs, PrintSupply, ProgrammableConfig, RevokeArgs,
TokenDelegateRole, TokenStandard, TransferArgs, UnlockArgs, UpdateArgs, VerificationArgs,
},
Expand Down Expand Up @@ -59,7 +62,7 @@ impl DirtyClone for DigitalAsset {
token: self.token,
edition: self.edition,
token_record: self.token_record,
token_standard: self.token_standard.clone(),
token_standard: self.token_standard,
edition_num: self.edition_num,
}
}
Expand Down Expand Up @@ -325,7 +328,7 @@ impl DigitalAsset {
is_mutable: true,
primary_sale_happened: false,
rule_set: authorization_rules,
token_standard: token_standard.clone(),
token_standard,
})
.instruction();

Expand Down Expand Up @@ -641,6 +644,16 @@ impl DigitalAsset {
builder.delegate_record(Some(delegate_record));
delegate_or_token_record = Some(delegate_record);
}
DelegateArgs::PrintDelegateV1 { .. } => {
let (delegate_record, _) = HolderDelegateRecord::find_pda(
&self.mint.pubkey(),
HolderDelegateRole::PrintDelegate,
&payer.pubkey(),
&delegate,
);
builder.delegate_record(Some(delegate_record));
delegate_or_token_record = Some(delegate_record);
}
}

// determines if we need to set the rule set
Expand Down Expand Up @@ -753,7 +766,7 @@ impl DigitalAsset {
token: Some(print_token.pubkey()),
metadata: print_metadata,
edition: Some(print_edition),
token_standard: self.token_standard.clone(),
token_standard: self.token_standard,
token_record: None,
edition_num: Some(edition_num),
})
Expand Down Expand Up @@ -857,6 +870,15 @@ impl DigitalAsset {
);
builder.delegate_record(Some(delegate_record));
}
RevokeArgs::PrintDelegateV1 { .. } => {
let (delegate_record, _) = HolderDelegateRecord::find_pda(
&self.mint.pubkey(),
HolderDelegateRole::PrintDelegate,
&payer.pubkey(),
&delegate,
);
builder.delegate_record(Some(delegate_record));
}
}

let revoke_ix = builder.revoke_args(args.clone()).instruction();
Expand Down Expand Up @@ -1143,7 +1165,7 @@ impl DigitalAsset {
&self,
context: &mut ProgramTestContext,
) -> Result<(), BanksClientError> {
match self.token_standard.clone().unwrap() {
match self.token_standard.unwrap() {
TokenStandard::NonFungible => {
self.non_fungigble_accounts_closed(context).await?;
}
Expand Down

0 comments on commit 91c9a0d

Please sign in to comment.