Add AuthorityType variant to use for mint close-authority adjustment (#3111)

This commit is contained in:
Tyera Eulberg 2022-04-26 09:55:15 -04:00 committed by GitHub
parent c616db83c4
commit 2491b29a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View File

@ -67,7 +67,7 @@ async fn set_authority() {
.set_authority(
token.get_address(),
Some(&new_authority.pubkey()),
instruction::AuthorityType::CloseAccount,
instruction::AuthorityType::CloseMint,
&wrong,
)
.await
@ -87,7 +87,7 @@ async fn set_authority() {
.set_authority(
token.get_address(),
Some(&new_authority.pubkey()),
instruction::AuthorityType::CloseAccount,
instruction::AuthorityType::CloseMint,
&close_authority,
)
.await
@ -104,7 +104,7 @@ async fn set_authority() {
.set_authority(
token.get_address(),
None,
instruction::AuthorityType::CloseAccount,
instruction::AuthorityType::CloseMint,
&new_authority,
)
.await
@ -118,7 +118,7 @@ async fn set_authority() {
.set_authority(
token.get_address(),
Some(&close_authority.pubkey()),
instruction::AuthorityType::CloseAccount,
instruction::AuthorityType::CloseMint,
&new_authority,
)
.await
@ -187,7 +187,7 @@ async fn fail_without_extension() {
.set_authority(
token.get_address(),
Some(&close_authority),
instruction::AuthorityType::CloseAccount,
instruction::AuthorityType::CloseMint,
&mint_authority,
)
.await

View File

@ -915,12 +915,14 @@ pub enum AuthorityType {
FreezeAccount,
/// Owner of a given token account
AccountOwner,
/// Authority to close a mint or token account
/// Authority to close a token account
CloseAccount,
/// Authority to set the transfer fee
TransferFeeConfig,
/// Authority to withdraw withheld tokens from a mint
WithheldWithdraw,
/// Authority to close a mint account
CloseMint,
}
impl AuthorityType {
@ -932,6 +934,7 @@ impl AuthorityType {
AuthorityType::CloseAccount => 3,
AuthorityType::TransferFeeConfig => 4,
AuthorityType::WithheldWithdraw => 5,
AuthorityType::CloseMint => 6,
}
}
@ -943,6 +946,7 @@ impl AuthorityType {
3 => Ok(AuthorityType::CloseAccount),
4 => Ok(AuthorityType::TransferFeeConfig),
5 => Ok(AuthorityType::WithheldWithdraw),
6 => Ok(AuthorityType::CloseMint),
_ => Err(TokenError::InvalidInstruction.into()),
}
}

View File

@ -610,7 +610,7 @@ impl Processor {
mint.base.freeze_authority = new_authority;
mint.pack_base();
}
AuthorityType::CloseAccount => {
AuthorityType::CloseMint => {
let extension = mint.get_extension_mut::<MintCloseAuthority>()?;
let maybe_close_authority: Option<Pubkey> = extension.close_authority.into();
let close_authority =