Skip to content

Commit

Permalink
royalties metadata check (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Giannis Chatziveroglou authored Sep 22, 2022
1 parent c64e4e6 commit dd73fb4
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use mpl_token_metadata::utils::assert_derivation;

use {
crate::{errors::ErrorCode, state::*},
anchor_lang::prelude::*,
Expand Down Expand Up @@ -45,6 +47,13 @@ pub fn handler<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts,
.expect("Division error");
let total_fees = maker_fee.checked_add(taker_fee).expect("Add error");

// assert metadata account derivation
assert_derivation(
&mpl_token_metadata::id(),
&ctx.accounts.mint_metadata.to_account_info(),
&[mpl_token_metadata::state::PREFIX.as_bytes(), mpl_token_metadata::id().as_ref(), ctx.accounts.mint.key().as_ref()],
)?;

// royalties
let mut fees_paid_out: u64 = 0;
if !ctx.accounts.mint_metadata.data_is_empty() {
Expand Down

0 comments on commit dd73fb4

Please sign in to comment.