Skip to content

Commit

Permalink
Merge branch 'main' of github.com:cardinal-labs/cardinal-token-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Giannis Chatziveroglou committed Sep 21, 2022
2 parents 80a82e2 + b74016e commit 3d6fc86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions programs/cardinal-payment-manager/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ pub enum ErrorCode {
InvalidTokenAccount,
#[msg("Invalid payment manager")]
InvalidPaymentManager,
#[msg("Mint metadata is owned by the incorrect program")]
InvalidMintMetadataOwner,
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ pub fn handler<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts,
// royalties
let mut fees_paid_out: u64 = 0;
if !ctx.accounts.mint_metadata.data_is_empty() {
if ctx.accounts.mint_metadata.to_account_info().owner.key() != mpl_token_metadata::id() {
return Err(error!(ErrorCode::InvalidMintMetadataOwner));
}
let mint_metadata_data = ctx.accounts.mint_metadata.try_borrow_mut_data().expect("Failed to borrow data");
let mint_metadata = Metadata::deserialize(&mut mint_metadata_data.as_ref())?;
let mint_metadata = Metadata::deserialize(&mut mint_metadata_data.as_ref()).expect("Failed to desirialize metadata");
if mint_metadata.mint != ctx.accounts.mint.key() {
return Err(error!(ErrorCode::InvalidMintMetadata));
}
Expand Down

0 comments on commit 3d6fc86

Please sign in to comment.