New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
token-2022: Add mint close authority support everywhere #2754
Conversation
token/program-2022/src/processor.rs
Outdated
expected_owner: &Pubkey, | ||
owner_account_info: &AccountInfo, | ||
owner_account_len: usize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be better to include "_data" here, to make it more clear what the length is from. Also same comment for all the call sites (eg. authority_info_len
-> authority_info_data_len
)
owner_account_len: usize, | |
owner_account_data_len: usize, |
token/program-2022/src/processor.rs
Outdated
} | ||
_ => { | ||
return Err(TokenError::AuthorityTypeNotSupported.into()); | ||
} | ||
} | ||
Mint::pack(mint, &mut account_info.data.borrow_mut())?; | ||
mint.pack_base(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess technically the pack_base()
is unnecessary for AuthorityType::CloseAccount
but trying to avoid this is probably more trouble than it's worth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good point, I'll move this up for freeze and mint and avoid this call, for sure
Builds on #2744 , only need to look at 4904516
Problem
The mint close authority must be properly supported in
set_authority
andclose_account
.Solution
Add the support.
Also, update
validate_owner
to accept the data length from the outside, since there were still double-borrow issues. Now, we pull out the data length right at the beginning, and use that later to see if the authority account is a multisig. Thankfully, if the authority is a multisig, then it can't be used for anything else in processing logic, meaning all double-borrows are avoided.