Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata to creator verification payload #32

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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