margin_trade: Allow forwarding mint accounts

This commit is contained in:
Christian Kamm 2022-05-26 21:12:02 +02:00
parent 536ec8a84a
commit 1844898280
1 changed files with 8 additions and 1 deletions

View File

@ -126,7 +126,14 @@ pub fn margin_trade<'key, 'accounts, 'remaining, 'info>(
if ai.owner != &TokenAccount::owner() {
return None;
}
let token_account = Account::<TokenAccount>::try_from(ai).unwrap();
// Skip mints and other accounts that may be owned by the spl_token program
let maybe_token_account = Account::<TokenAccount>::try_from(ai);
if maybe_token_account.is_err() {
return None;
}
let token_account = maybe_token_account.unwrap();
if token_account.owner != ctx.accounts.group.key() {
return None;
}