Skip to content
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

Merged
merged 2 commits into from Jan 19, 2022

Conversation

joncinque
Copy link
Contributor

Builds on #2744 , only need to look at 4904516

Problem

The mint close authority must be properly supported in set_authority and close_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.

@joncinque joncinque marked this pull request as ready for review January 18, 2022 23:11
@joncinque joncinque requested a review from mvines January 18, 2022 23:11
@joncinque joncinque added this to In progress in SPL Token Extensions Jan 18, 2022
@joncinque joncinque removed this from In progress in SPL Token Extensions Jan 18, 2022
expected_owner: &Pubkey,
owner_account_info: &AccountInfo,
owner_account_len: usize,
Copy link
Member

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)

Suggested change
owner_account_len: usize,
owner_account_data_len: usize,

}
_ => {
return Err(TokenError::AuthorityTypeNotSupported.into());
}
}
Mint::pack(mint, &mut account_info.data.borrow_mut())?;
mint.pack_base();
Copy link
Member

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

Copy link
Contributor Author

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

@joncinque joncinque merged commit db0b2c5 into solana-labs:master Jan 19, 2022
@joncinque joncinque deleted the tk-close branch January 19, 2022 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants