Skip to content

Commit

Permalink
Add metadata to creator verification payload (#32)
Browse files Browse the repository at this point in the history
* Add metadata to creator verification payload

* Set SPL token to specific version
  • Loading branch information
danenbm authored Dec 21, 2023
1 parent 22b3079 commit 41284ef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blockbuster/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mpl-candy-guard = { version = "2.0.0", features = ["no-entrypoint"] }
mpl-candy-machine-core = { version = "2.0.0", features = ["no-entrypoint"] }
mpl-token-metadata = { version = "2.0.0-beta.1", features = ["no-entrypoint", "serde-feature"] }
plerkle_serialization = { version = "1.6.0" }
spl-token = { version = ">= 3.5.0, < 5.0", features = ["no-entrypoint"] }
spl-token = { version = "4.0.0", features = ["no-entrypoint"] }
async-trait = "0.1.57"
bs58 = "0.4.0"
lazy_static = "1.4.0"
Expand Down
20 changes: 17 additions & 3 deletions blockbuster/src/programs/bubblegum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use crate::{program_handler::NotUsed, programs::ProgramParseResult};
use borsh::de::BorshDeserialize;
use mpl_bubblegum::{
get_instruction_type,
instructions::UpdateMetadataInstructionArgs,
instructions::{
UnverifyCreatorInstructionArgs, UpdateMetadataInstructionArgs, VerifyCreatorInstructionArgs,
},
types::{BubblegumEventType, MetadataArgs, UpdateArgs},
};
pub use mpl_bubblegum::{types::LeafSchema, InstructionName, LeafSchemaEvent, ID};
Expand Down Expand Up @@ -38,6 +40,7 @@ pub enum Payload {
root: [u8; 32],
},
CreatorVerification {
metadata: MetadataArgs,
creator: Pubkey,
verify: bool,
},
Expand Down Expand Up @@ -202,10 +205,12 @@ impl ProgramParser for BubblegumParser {
b_inst.payload = Some(Payload::CancelRedeem { root: slice });
}
InstructionName::VerifyCreator => {
b_inst.payload = Some(build_creator_verification_payload(keys, true)?);
b_inst.payload =
Some(build_creator_verification_payload(keys, ix_data, true)?);
}
InstructionName::UnverifyCreator => {
b_inst.payload = Some(build_creator_verification_payload(keys, false)?);
b_inst.payload =
Some(build_creator_verification_payload(keys, ix_data, false)?);
}
InstructionName::VerifyCollection | InstructionName::SetAndVerifyCollection => {
b_inst.payload = Some(build_collection_verification_payload(keys, true)?);
Expand All @@ -229,13 +234,22 @@ impl ProgramParser for BubblegumParser {
// https://github.com/metaplex-foundation/mpl-bubblegum/blob/main/programs/bubblegum/README.md#-verify_creator-and-unverify_creator
fn build_creator_verification_payload(
keys: &[plerkle_serialization::Pubkey],
ix_data: &[u8],
verify: bool,
) -> Result<Payload, BlockbusterError> {
let metadata = if verify {
VerifyCreatorInstructionArgs::try_from_slice(ix_data)?.metadata
} else {
UnverifyCreatorInstructionArgs::try_from_slice(ix_data)?.metadata
};

let creator = keys
.get(5)
.ok_or(BlockbusterError::InstructionParsingError)?
.0;

Ok(Payload::CreatorVerification {
metadata,
creator: Pubkey::new_from_array(creator),
verify,
})
Expand Down

0 comments on commit 41284ef

Please sign in to comment.