Skip to content

Commit

Permalink
all bgum events done
Browse files Browse the repository at this point in the history
  • Loading branch information
austbot committed Jun 20, 2022
1 parent 27e3fd6 commit a67db30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions contracts/programs/bubblegum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use {
Nonce, Voucher,
metaplex_adapter::{MetadataArgs, TokenProgramVersion},
NewNFTEvent,
NFTDecompressionEvent
},
gummyroll::{program::Gummyroll, Node},
crate::error::BubblegumError,
Expand Down Expand Up @@ -585,10 +586,11 @@ pub mod bubblegum {
pub fn decompress_v1(ctx: Context<DecompressV1>, metadata: MetadataArgs) -> Result<()> {
// Allocate and create mint
let incoming_data_hash = hash_metadata(&metadata)?;
match ctx.accounts.voucher.leaf_schema {
let event = match ctx.accounts.voucher.leaf_schema {
LeafSchema::V1 {
owner,
data_hash,
nonce,
..
} => {
if !cmp_bytes(&data_hash, &incoming_data_hash, 32) {
Expand All @@ -597,8 +599,14 @@ pub mod bubblegum {
if !cmp_pubkeys(&owner, ctx.accounts.owner.key) {
return Err(BubblegumError::AssetOwnerMismatch.into());
}
Ok::<(), ProgramError>(())
Ok(NFTDecompressionEvent {
version: Version::V1,
tree_id: ctx.accounts.voucher.merkle_slab.key(),
id: get_asset_id(&ctx.accounts.voucher.merkle_slab.key(), nonce),
nonce: nonce
})
}
_ => Err(BubblegumError::UnsupportedSchemaVersion)
}?;
let voucher = &ctx.accounts.voucher;
match metadata.token_program_version {
Expand Down Expand Up @@ -756,6 +764,7 @@ pub mod bubblegum {
&[ctx.bumps["mint_authority"]],
]],
)?;
emit!(event);
Ok(())
}

Expand Down
9 changes: 9 additions & 0 deletions contracts/programs/bubblegum/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ impl Voucher {
}
}
}

#[event]
pub struct NewNFTEvent {
pub version: Version,
pub metadata: MetadataArgs,
pub nonce: u64,
}

#[event]
pub struct NFTDecompressionEvent {
pub version: Version,
pub id: Pubkey,
pub tree_id: Pubkey,
pub nonce: u64,
}

0 comments on commit a67db30

Please sign in to comment.