Skip to content

Commit

Permalink
Fixing incorrect owner check for holder delegate. (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus authored Apr 9, 2024
1 parent 3a3884e commit 9485552
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions programs/token-metadata/program/src/processor/delegate/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use spl_token_2022::{instruction::AuthorityType as SplAuthorityType, state::Acco
use crate::{
assertions::{
assert_derivation, assert_keys_equal, assert_owned_by, assert_owner_in,
metadata::assert_update_authority_is_correct,
metadata::{assert_holding_amount, assert_update_authority_is_correct},
},
error::MetadataError,
instruction::{Context, Delegate, DelegateArgs, HolderDelegateRole, MetadataDelegateRole},
Expand Down Expand Up @@ -223,15 +223,16 @@ fn create_other_delegate_v1(
}
};

// ownership for token
assert_owner_in(token_info, &SPL_TOKEN_PROGRAM_IDS)?;

// authority must be the owner of the token account: spl-token required the
// token owner to set a delegate
let token = unpack::<Account>(&token_info.try_borrow_data()?)?;
if token.owner != *ctx.accounts.authority_info.key {
return Err(MetadataError::IncorrectOwner.into());
}
// Check if the owner is accurate the token accounts are correct.
assert_holding_amount(
program_id,
ctx.accounts.authority_info,
ctx.accounts.metadata_info,
&metadata,
ctx.accounts.mint_info,
token_info,
1,
)?;
}
_ => return Err(MetadataError::InvalidDelegateRole.into()),
}
Expand Down

0 comments on commit 9485552

Please sign in to comment.